//
//  LKUFOpenShopBottomButtonRowCell.m
//  Mideleague_Shop
//
//  Created by Zhiwang on 2020/6/4.
//  Copyright © 2020 Zhiwang. All rights reserved.
//

#import "LKUFOpenShopBottomButtonRowCell.h"
#import "LKUFOpenShopBottomButtonRow.h"
#import "LKDefineFile.h"
#import "LKBaseView.h"
#import <SVProgressHUD/SVProgressHUD.h>
@interface LKUFOpenShopBottomButtonRowCell()


@property(nonatomic,strong)LKUFOpenShopBottomButtonRow *buttonrow;

@property(nonatomic,strong)LKBaseButton *nextBtn;
@property(nonatomic,strong)LKBaseButton *protalAgreeBtn;
@property(nonatomic,strong)LKBaseButton *ProtalABtn;
@property(nonatomic,strong)LKBaseButton *ProtalBBtn;
@end
@implementation LKUFOpenShopBottomButtonRowCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        WS(weakSelf)
        self.contentView.backgroundColor = viewDefualtColor;
        self.nextBtn = [LKBaseButton buttonWithFrame:CGRectMake(10, 30, WIDTH - 20, 50) type:UIButtonTypeCustom title:@"下一步" titleColor:[UIColor whiteColor] layercorne:25 font:[UIFont fontWithName:@"PingFangSC-Regular" size:18] backgroudColor:yellowDefaultColor AndActionBlock:^(UIButton * _Nonnull btn) {
            if (weakSelf.protalAgreeBtn.selected) {
                [SVProgressHUD showInfoWithStatus:@"请先勾选并同意协议"];
                return ;
            }
            if (weakSelf.buttonrow.actionBlock) {
                weakSelf.buttonrow.actionBlock();
            }
        }];
        [self.contentView addSubview:_nextBtn];
    }
    return self;
}


-(void)setRow:(__kindof UFRow *)row{
    WS(weakSelf)
    _buttonrow = row;
    [super setRow:row];
    if (_buttonrow.isContainProtcoal) {
        self.protalAgreeBtn = [LKBaseButton buttonWithFrame:CGRectZero type:UIButtonTypeCustom title:@" 阅读以下协议并同意" titleColor:COLOR_HEX(0x666666) layercorne:0 font:[UIFont fontWithName:@"PingFangSC-Regular" size:12] backgroudColor:viewDefualtColor AndActionBlock:^(UIButton * _Nonnull btn) {
            btn.selected = !btn.selected;
            if (weakSelf.buttonrow.agreeBtnBlock) {
             weakSelf.buttonrow.agreeBtnBlock();
            }
        }];
        [self.protalAgreeBtn setImage:[UIImage imageNamed:@"weixuanzhong_customer"] forState:UIControlStateSelected];
        [self.protalAgreeBtn setImage:[UIImage imageNamed:@"xuanzhong_customer"] forState:UIControlStateNormal];
        [self.contentView addSubview:self.protalAgreeBtn];
        [self.protalAgreeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(10);
            make.top.equalTo(self.contentView).offset(15);
        }];
        self.ProtalABtn = [LKBaseButton buttonWithFrame:CGRectZero type:UIButtonTypeCustom title:@"《随行付商户服务协议》" titleColor:yellowDefaultColor layercorne:0 font:[UIFont fontWithName:@"PingFangSC-Regular" size:12] backgroudColor:viewDefualtColor AndActionBlock:^(UIButton * _Nonnull btn) {
            if (weakSelf.buttonrow.protcalABtnBlock) {
                weakSelf.buttonrow.protcalABtnBlock();
            }
               }];
            [self.contentView addSubview:self.ProtalABtn];
           [self.ProtalABtn mas_makeConstraints:^(MASConstraintMaker *make) {
               make.left.equalTo(self.contentView).offset(10);
               make.top.equalTo(self.protalAgreeBtn.mas_bottom).offset(2);
           }];
        self.ProtalBBtn = [LKBaseButton buttonWithFrame:CGRectZero type:UIButtonTypeCustom title:@"《米德支点服务隐私政策条款》" titleColor:yellowDefaultColor layercorne:0 font:[UIFont fontWithName:@"PingFangSC-Regular" size:12] backgroudColor:viewDefualtColor AndActionBlock:^(UIButton * _Nonnull btn) {
        if (weakSelf.buttonrow.protcalBBtnBlock) {
            weakSelf.buttonrow.protcalBBtnBlock();
        }
               }];
           [self.contentView addSubview:self.ProtalBBtn];
           [self.ProtalBBtn mas_makeConstraints:^(MASConstraintMaker *make) {
               make.left.equalTo(self.ProtalABtn.mas_right).offset(2);
               make.centerY.equalTo(self.ProtalABtn);
           }];
        [self.nextBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(10);
            make.right.equalTo(self.contentView).offset(-10);
            make.top.equalTo(self.ProtalABtn.mas_bottom).offset(30);
            make.height.mas_equalTo(50);
        }];
    }
    if (_buttonrow.buttonTitle) {
        [self.nextBtn setTitle:_buttonrow.buttonTitle forState:UIControlStateNormal];
    }

}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
